package com.yao.util;

import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;

/**
 * @author 妖悲冥
 * @date 2021/5/24 0024   -    8:51
 */
@Component
public class SaveFile {
    public void save(MultipartFile file, String username) {
        File f = new File("D:\\IDEA\\SpringBoot+Vue\\img\\", username + ".jpg");
        try {
            // 得到MultipartFile文件
            file.transferTo(f);
            // 读取文件第一行
            BufferedReader bufferedReader = null;
            bufferedReader = new BufferedReader(new FileReader(f));
            // 输出绝对路径
            bufferedReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
